﻿
Public Class dmnGrid
    Private m_Picture As New DrawablePicture(Me.BackColor)
    Private _Rows As Integer = 20
    Private _Cols As Integer = 1

    Public Property Cols() As Integer
        Get
            Return _Cols
        End Get
        Set(ByVal value As Integer)
            _Cols = value
        End Set
    End Property

    Public Property Rows() As Integer
        Get
            Return _Rows
        End Get
        Set(ByVal value As Integer)
            _Rows = value
        End Set
    End Property

    Private Sub picCanvas_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picCanvas.Paint
        m_Picture.Draw(e.Graphics)
    End Sub

    Private Sub picCanvas_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles picCanvas.Resize
        DrawBackGround()
    End Sub

    Private Sub DrawBackGround()
        For iCols As Integer = 1 To _Cols
            For iRows As Integer = 1 To _Rows
                Dim lCell As DrawableCell = New DrawableCell(Color.Black, _
                                                             Color.WhiteSmoke, _
                                                             1, _
                                                             iCols, _
                                                             iRows * 20, _
                                                             80, _
                                                             (iRows * 20) + 40)

                m_Picture.Add(lCell)
                picCanvas.Height = (iRows * 20) + 40
            Next
        Next

    End Sub
End Class

